<template>
  <input ref="wkFileInput" :name="data.name"
    :multiple="data.multiple" :accept="data.accept"
    style="display: none;" type="file" @change="handleChange" >
</template>

<script setup>
import merge from '/src/utils/merge.js'
import {ref} from "vue"

const DefaultWkFileSelectData = {
  name: 'file',
  accept: '*.*',
  multiple: true
}

defineOptions({
  // 附件选择
  name: 'WkFile',
})

const  data = ref({})
const resolve =  ref(null)
const wkFileInput = ref();


function handleChange(ev) {
  resolve.value(ev)
}

function select(data) {
  data.value = merge({ ...DefaultWkFileSelectData }, data || {})
  // 将input置空
  wkFileInput.value.value = null
  // 执行input的click操作
  wkFileInput.value.click()
  return new Promise((resolve, reject) => {
    resolve.value = resolve
  })
}
</script>


<script>


export default {


  components: {},

  props: {},

  data() {
    return {

    }
  },

  computed: {},

  watch: {},

  created() {},

  mounted() {
  },

  beforeDestroy() {},

  methods: {

  }
}
</script>

<style lang="scss" scoped>

</style>
